<table class="tbl" border="1" style="table-layout:auto; width:820px;" id="tb">
    <thead> 
        <tr style="font-size:13px;"> <td>STT</td> <td>Họ tên</td> <td>Học vị</td> <td>Môn giảng dạy</td> <td colspan="2">Lựa chọn</td> </tr>
    </thead>
    <tbody>
        <?php
            $i = 1;	$display = 10; static $id_gv;
            if( isset($_GET['page']) && (int)$_GET['page'] )
                $page = $_GET['page'];
            else
            {
                $query = mysql_query(" SELECT count(id) FROM teachers WHERE name != '' ");
                $row = mysql_fetch_array($query,MYSQLI_NUM);
                $total_row = $row['0'];
                if($total_row > $display)
                    $page = ceil($total_row/$display);
                else
                    $page = 1;
            }
            $start = ( isset($_GET['start']) && (int)$_GET['start'] >= 0 ) ? $_GET['start'] : 0;
            $sql = mysql_query(" SELECT a.id,a.name,degree,b.name as subject FROM teachers a join subject b on a.subject = b.id
                                    WHERE a.name != '' ORDER BY b.id LIMIT $start,$display ");
            if(mysql_num_rows($sql) > 0)
            {
                while($row = mysql_fetch_array($sql))
                {
                    $id = $row['id'];
                    $name = $row['name'];
                    $degree = $row['degree'];
                    echo "<tr>";
                        echo "<td>".$i."</td>";
                        echo "<td>".ucwords($name)."</td>";
                        echo "<td>".ucwords($degree)."</td>";
                        echo "<td>".ucwords($row['subject'])."</td>";
                        echo "<td> <a href='index.php?p=lst_tea&opt=ed&eid={$id}' class='option'> Sửa </a> </td>";
                        echo "<td> <a href='teacher/delete.php?id=$id' class='option' onClick=\"return confirm('Bạn có thực sự muốn xóa giáo viên {$name} ?')\"> Xóa </a> </td>";
                        $i++;
                    echo "</tr>";
                }
            }
            else
                echo "<tr> <td colspan='7'> Chưa có giáo viên </td> </tr>";
        ?>
    </tbody>
</table>
<table class="nav">
	<?php
		if($page > 1)
		{
			$prev = $start - $display ;
			$next = $start + $display;
			$current = ($start/$display) + 1;
			echo "<tr>";
			for($i=1 ; $i<=$page ; $i++)
			{
				if($current != $i)
					echo "<td><a href='index.php?p=lst_tea&start=".($display*($i-1))."&page=$page#tb' style='color:#fff;'>Trang $i</a></td>";
				else
					echo " <td class='current'> Trang $i </td> ";
			}

			echo "</tr>";
		}
	?>
</table>
<div class="message">
<?php
	if(isset($_GET['msg']))
	{
		if($_GET['msg'] == "update_success")	
		{
			echo "Cập nhật thành công";	
		}
	}
?>
</div>